﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="SystemData.aspx.cs" Inherits="TempEmployees.Web.SystemData" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div style="direction: ltr">
        <fieldset>
            <legend class="legend">Add Semesters</legend>
            <table>
                <tr>
                    <td>
                        <p>
                            Name:&nbsp;<asp:TextBox ID="TextboxSemesterName" runat="server"></asp:TextBox></p>
                        <p>
                            Date Format: dd/MM/yyyy (17/09/2011)</p>
                        <p>
                            Start:&nbsp;&nbsp;&nbsp;<asp:TextBox ID="TextboxStartDate" runat="server"></asp:TextBox></p>
                        <p>
                            End:&nbsp;&nbsp;&nbsp;&nbsp;<asp:TextBox ID="TextboxEndDate" runat="server"></asp:TextBox></p>
                        <p>
                            <asp:Button ID="ButtonAddSemester" runat="server" Text="Add" OnClick="ButtonAddSemester_Click" /></p>
                        <p>
                            <asp:Label ID="LabelSemesterMessage" runat="server" Text=""></asp:Label></p>
                    </td>
                    <td style="vertical-align:top">
                        <asp:GridView ID="SemestersGridView" runat="server" AllowPaging="True" 
                            AllowSorting="True" AutoGenerateColumns="False" 
                            DataSourceID="SemestersDataSource" DataKeyNames="ID">
                            <Columns>
                                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                                <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" ReadOnly="true" />
                                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                <asp:BoundField DataField="StartDate" HeaderText="Start Date" SortExpression="StartDate" DataFormatString="{0:dd/MM/yyyy}" />
                                <asp:BoundField DataField="EndDate" HeaderText="End Date" SortExpression="EndDate" DataFormatString="{0:dd/MM/yyyy}" />
                            </Columns>
                        </asp:GridView>
                    </td>
                </tr>
            </table>
        </fieldset>
        <fieldset>
            <legend class="legend">Add Departments</legend>
            <table>
                <tr>
                    <td>
                        <p>
                            Name:&nbsp;<asp:TextBox ID="TextBoxDepName" Text="" runat="server"></asp:TextBox></p>
                        <p>
                            <asp:Button ID="ButtonAddDep" runat="server" Text="Add" OnClick="ButtonAddDep_Click" /></p>
                        <p>
                            <asp:Label ID="LabelDepMessage" runat="server" Text=""></asp:Label></p>
                    </td>
                    <td style="vertical-align:top">
                        <asp:GridView ID="DepartmentsGridView" runat="server" AllowPaging="True" 
                            AllowSorting="True" AutoGenerateColumns="False" 
                            DataSourceID="DepartmentsDataSource" DataKeyNames="ID">
                            <Columns>
                                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                                <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" ReadOnly="true" />
                                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                <asp:BoundField DataField="NameInActiveDirectory" HeaderText="Active Directory - DN" SortExpression="NameInActiveDirectory" />
                            </Columns>
                        </asp:GridView>
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>
    <asp:SqlDataSource ID="SemestersDataSource" runat="server" ConflictDetection="CompareAllValues"
        ConnectionString="<%$ ConnectionStrings:TempEmpDataBaseConnectionString %>" DeleteCommand="DELETE FROM [Semesters] WHERE [ID] = @original_ID AND [StartDate] = @original_StartDate AND [EndDate] = @original_EndDate AND [Name] = @original_Name"
        InsertCommand="INSERT INTO [Semesters] ([StartDate], [EndDate], [Name]) VALUES (@StartDate, @EndDate, @Name)"
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [Semesters] ORDER BY [StartDate] DESC"
        UpdateCommand="UPDATE [Semesters] SET [StartDate] = @StartDate, [EndDate] = @EndDate, [Name] = @Name WHERE [ID] = @original_ID AND [StartDate] = @original_StartDate AND [EndDate] = @original_EndDate AND [Name] = @original_Name">
        <DeleteParameters>
            <asp:Parameter Name="original_ID" Type="Int32" />
            <asp:Parameter Name="original_StartDate" Type="DateTime" />
            <asp:Parameter Name="original_EndDate" Type="DateTime" />
            <asp:Parameter Name="original_Name" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="StartDate" Type="DateTime" />
            <asp:Parameter Name="EndDate" Type="DateTime" />
            <asp:Parameter Name="Name" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="StartDate" Type="DateTime" />
            <asp:Parameter Name="EndDate" Type="DateTime" />
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="original_ID" Type="Int32" />
            <asp:Parameter Name="original_StartDate" Type="DateTime" />
            <asp:Parameter Name="original_EndDate" Type="DateTime" />
            <asp:Parameter Name="original_Name" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="DepartmentsDataSource" runat="server" ConflictDetection="CompareAllValues"
        
        ConnectionString="<%$ ConnectionStrings:TempEmpDataBaseConnectionString %>" DeleteCommand="DELETE FROM [Departments] WHERE [ID] = @original_ID AND (([Name] = @original_Name) OR ([Name] IS NULL AND @original_Name IS NULL)) AND (([NameInActiveDirectory] = @original_NameInActiveDirectory) OR ([NameInActiveDirectory] IS NULL AND @original_NameInActiveDirectory IS NULL))"
        
        InsertCommand="INSERT INTO [Departments] ([Name], [NameInActiveDirectory]) VALUES (@Name, @NameInActiveDirectory)" OldValuesParameterFormatString="original_{0}"
        SelectCommand="SELECT * FROM [Departments]" 
        UpdateCommand="UPDATE [Departments] SET [Name] = @Name, [NameInActiveDirectory] = @NameInActiveDirectory WHERE [ID] = @original_ID AND (([Name] = @original_Name) OR ([Name] IS NULL AND @original_Name IS NULL)) AND (([NameInActiveDirectory] = @original_NameInActiveDirectory) OR ([NameInActiveDirectory] IS NULL AND @original_NameInActiveDirectory IS NULL))">
        <DeleteParameters>
            <asp:Parameter Name="original_ID" Type="Int32" />
            <asp:Parameter Name="original_Name" Type="String" />
            <asp:Parameter Name="original_NameInActiveDirectory" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="NameInActiveDirectory" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="NameInActiveDirectory" Type="String" />
            <asp:Parameter Name="original_ID" Type="Int32" />
            <asp:Parameter Name="original_Name" Type="String" />
            <asp:Parameter Name="original_NameInActiveDirectory" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>
